package org.example.src.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * 应用自定义配置属性类
 * 用于读取application.properties中以app开头的配置项
 */
@Component
@ConfigurationProperties(prefix = "app")
public class AppProperties {

    private final Cors cors = new Cors();
    private final File file = new File();

    /**
     * CORS配置内部类
     */
    public static class Cors {
        private String allowedOrigins = "*";

        // Getter和Setter方法
        public String getAllowedOrigins() {
            return allowedOrigins;
        }

        public void setAllowedOrigins(String allowedOrigins) {
            this.allowedOrigins = allowedOrigins;
        }
    }

    /**
     * 文件配置内部类
     */
    public static class File {
        private String uploadDir = "./uploads";

        // Getter和Setter方法
        public String getUploadDir() {
            return uploadDir;
        }

        public void setUploadDir(String uploadDir) {
            this.uploadDir = uploadDir;
        }
    }

    // 外部类的Getter方法
    public Cors getCors() {
        return cors;
    }

    public File getFile() {
        return file;
    }
}
